<template>
    <div>
        <span>用户名：</span>
        <input type="text" v-model="user.userName">
      <span>密码：</span>
      <input type="password" v-model="user.userPwd">
      <button type="button" @click="jqueryGet">jquery的get请求</button>
      <button type="button">jquery的post请求</button>
      <button type="button" @click="axiosGet">axios的get请求</button>
      <button type="button"@click="axiosPost">axios的post请求</button>
    </div>

</template>

<script>


    export default {
        name: "TestAios",
        data(){
          return{
              user:{
                userName:"admin",
                userPwd:"123"
              }
          }
        },
        methods:{
             jqueryGet(){
                $.ajax({
                   url:"/exam/test/loginGet",
                   type:"get",
                   data:this.user,
                   success:function (rs) {
                        if(rs.code==200){
                           alert(rs.msg);
                        }else{
                           alert(rs.msg);
                        }
                   }

                })
             },
           axiosGet(){
                this.$http.get("/test/loginGet",{params:this.user})
                .then(function (rs) {//成功的回调函数
                  if(rs.data.code==200){
                    alert(rs.data.msg);
                  }else{
                    alert(rs.data.msg);
                  }
                }).catch(function (rs) {//失败的回调函数

                })
           },
           axiosPost(){
             this.$http.post("/test/loginPost",this.$qs.stringify(this.user))
               .then(function (rs) {//成功的回调函数
                 if(rs.data.code==200){
                   alert(rs.data.msg);
                 }else{
                   alert(rs.data.msg);
                 }
               }).catch(function (rs) {//失败的回调函数

             })
           }

        }
    }
</script>

<style scoped>

</style>
